#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int ws = 0;
	int sum = 0, rem0, rem1;
	for (int digit = 0; digit < 100000; digit++) {
		ws = 0;
		for (int i = digit; i > 0; i /= 10)
			ws++;
		sum = 0;
		for (int i = digit; i > 0; i /= 10) {
			rem1 = rem0 = i % 10;
			for (int j = 0; j < ws - 1; j++)
				rem1 *= rem0;
			sum += rem1;
		}
		if (sum == digit)
			printf("%d ", digit);
	}
	return 0;
}